package icegps.com.bhmap.threadpool;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 * Created by 111 on 2017/12/13.
 */

public class ThreadPool {
    private volatile static ThreadPool threadPool;
    private final ExecutorService executorService;

    public static ThreadPool getInstance() {
        if (threadPool == null) {
            synchronized (ThreadPool.class) {
                if (threadPool == null) {
                    threadPool = new ThreadPool();
                }
            }
        }
        return threadPool;
    }

    private ThreadPool() {
        executorService = Executors.newSingleThreadExecutor();

    }

    public void execute(Runnable runnable) {
        executorService.execute(runnable);
    }
}
